﻿using Hidistro.Entities.Commodities;
using Hidistro.SaleSystem.Catalog;
using Hidistro.UI.Common.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class wnxd_AllBrand : AscxTemplatedWebControl
    {
        int i = 0;
        protected override void AttachChildControls()
        {
            Repeater calist = (Repeater)this.FindControl("calist");
            Repeater clist = (Repeater)this.FindControl("clist");
            IList<CategoryInfo> ca = CategoryBrowser.GetMaxMainCategories(0x3e8);
            calist.DataSource = ca;
            calist.DataBind();
            clist.ItemDataBound += clist_ItemDataBound;
            clist.DataSource = ca;
            clist.DataBind();
        }

        void clist_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                HtmlGenericControl box = (HtmlGenericControl)e.Item.FindControl("box");
                if (i > 0) box.Attributes.Add("style", "display: none;");
                Repeater blist = (Repeater)e.Item.FindControl("blist");
                blist.DataSource = CategoryBrowser.GetBrandCategories(((CategoryInfo)e.Item.DataItem).CategoryId);
                blist.DataBind();
                i++;
            }
        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "/ascx/tags/wnxd_AllBrand.ascx";
            }
            base.OnInit(e);
        }
    }
}
